package Algorithm.Greedy;

// 最长能覆盖几个点
public class Code01_CordCoverMaxPoint {
    public static void main(String[] args){
        int[] arr = {2,7,15,19,23,34};
        int L = 8;
        System.out.println(maxPoint(arr, L));
    }

    public static int maxPoint(int[] arr, int L){
        int left = 0;
        int right = 0;
        int N = arr.length;
        int max = 0;
        while (left < N){
            while (right < N && arr[right] - arr[left] <= L){
                right ++;
            }
            max = Math.max(max, right - (left++));
        }
        return max;
    }
}
